{{define "system/dict/type/add"}}
<!DOCTYPE html>
<html lang="zh">
<head>
	{{template "header" (OssUrl)}}
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content   ibox-content">
		<form class="form-horizontal m" id="form-dict-add">
			<div class="form-group">
				<label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label ">字典名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="dictName" id="dictName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">字典类型：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="dictType" id="dictType" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">状态：</label>
				<div class="col-sm-8">
					{{DictRadio "sys_normal_disable" "status" "0"}}
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control"></textarea>
				</div>
			</div>
		</form>
	</div>
	{{template "footer" (OssUrl)}}
	<script type="text/javascript">
		var prefix = ctx + "/system/dict";
	
		$("#form-dict-add").validate({
			onkeyup: false,
			rules:{
				dictType:{
					minlength: 5,
					remote: {
		                url: prefix + "/checkDictTypeUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	name : function() {
		                        return $.common.trim($("#dictType").val());
		                    }
		                },
						dataFilter: function(response) {
							let json = $.parseJSON(response);
							let exist = json.data
							if (json.code == 200 && exist == false) {//不
								return true;
							}else{
								return "\"" + json.msg + "\"";
							}
							return true;
						}
					}
				},
			},
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-dict-add').serialize());
	        }
	    }
	</script>
</body>
</html>
{{end}}